/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


/**
 *
 * @author sflesca
 */
@Entity
@Table(name = "cliente")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cliente.findAll", query = "SELECT c FROM Cliente c"),
    @NamedQuery(name = "Cliente.findById", query = "SELECT c FROM Cliente c WHERE c.id = :id"),
    @NamedQuery(name = "Cliente.findByNumeroTessera", query = "SELECT c FROM Cliente c WHERE c.numeroTessera = :numeroTessera")})
public class Cliente extends Persona implements Serializable {
    private static final long serialVersionUID = 1L;
    @Size(max = 255)
    @Column(name = "NUMEROTESSERA")
    private String numeroTessera;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "clienteID")
    private Collection<Coupon> couponCollection;
    @OneToMany(mappedBy = "cliente")
    private List<Ordine> ordini;


    /**
     * Get the value of numeroTessera
     *
     * @return the value of numeroTessera
     */
    public String getNumeroTessera() {
        return numeroTessera;
    }

    /**
     * Set the value of numeroTessera
     *
     * @param numeroTessera new value of numeroTessera
     */
    public void setNumeroTessera(String numeroTessera) {
        this.numeroTessera = numeroTessera;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getId() != null ? getId().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cliente)) {
            return false;
        }
        Cliente other = (Cliente) object;
        if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.getId().equals(other.getId()))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Cliente[id=" + getId() + "]";
    }

    public Cliente() {
    }

    public Cliente(Long id) {
        this.setId(id);
    }

    public Collection<Coupon> getCouponCollection() {
        return couponCollection;
    }

    public void setCouponCollection(Collection<Coupon> couponCollection) {
        this.couponCollection = couponCollection;
    }

}
